package com.ruoyi.jiuzai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiuzai.domain.Gongyingshang;
import com.ruoyi.jiuzai.service.IGongyingshangService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产商名录Controller
 * 
 * @author ruoyi
 * @date 2025-06-21
 */
@RestController
@RequestMapping("/gongyingshang/gongyingshang")
public class GongyingshangController extends BaseController
{
    @Autowired
    private IGongyingshangService gongyingshangService;

    /**
     * 查询生产商名录列表
     */
    @PreAuthorize("@ss.hasPermi('gongyingshang:gongyingshang:list')")
    @GetMapping("/list")
    public TableDataInfo list(Gongyingshang gongyingshang)
    {
        startPage();
        List<Gongyingshang> list = gongyingshangService.selectGongyingshangList(gongyingshang);
        return getDataTable(list);
    }

    /**
     * 导出生产商名录列表
     */
    @PreAuthorize("@ss.hasPermi('gongyingshang:gongyingshang:export')")
    @Log(title = "生产商名录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Gongyingshang gongyingshang)
    {
        List<Gongyingshang> list = gongyingshangService.selectGongyingshangList(gongyingshang);
        ExcelUtil<Gongyingshang> util = new ExcelUtil<Gongyingshang>(Gongyingshang.class);
        util.exportExcel(response, list, "生产商名录数据");
    }

    /**
     * 获取生产商名录详细信息
     */
    @PreAuthorize("@ss.hasPermi('gongyingshang:gongyingshang:query')")
    @GetMapping(value = "/{sId}")
    public AjaxResult getInfo(@PathVariable("sId") Long sId)
    {
        return success(gongyingshangService.selectGongyingshangBySId(sId));
    }

    /**
     * 新增生产商名录
     */
    @PreAuthorize("@ss.hasPermi('gongyingshang:gongyingshang:add')")
    @Log(title = "生产商名录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Gongyingshang gongyingshang)
    {
        return toAjax(gongyingshangService.insertGongyingshang(gongyingshang));
    }

    /**
     * 修改生产商名录
     */
    @PreAuthorize("@ss.hasPermi('gongyingshang:gongyingshang:edit')")
    @Log(title = "生产商名录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Gongyingshang gongyingshang)
    {
        return toAjax(gongyingshangService.updateGongyingshang(gongyingshang));
    }

    /**
     * 删除生产商名录
     */
    @PreAuthorize("@ss.hasPermi('gongyingshang:gongyingshang:remove')")
    @Log(title = "生产商名录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sIds}")
    public AjaxResult remove(@PathVariable Long[] sIds)
    {
        return toAjax(gongyingshangService.deleteGongyingshangBySIds(sIds));
    }
}
